package com.easy.orm.jdbc.transactional;

import java.sql.Connection;
import java.sql.SQLException;

/**
 * 事务操作接口
 * 
 * @author kun
 *
 */
public interface TransactionalOperationsInterface {

	/**
	 * 获取事务连接
	 * 
	 * @return {@linkplain java.sql.Connection}
	 */
	Connection getTransactionalConnection();

	/**
	 * 设置事务连接
	 * 
	 * @param transactionalConnection {@linkplain java.sql.Connection}
	 */
	void setTransactionalConnection(Connection transactionalConnection);

	/**
	 * 关闭 连接
	 *
	 * @throws SQLException 执行异常
	 *             <p>
	 *             {@linkplain java.sql.Connection#close()}
	 *             </p>
	 *             <p>
	 *             {@linkplain java.sql.Statement#close()}
	 *             </p>
	 *             <p>
	 *             {@linkplain java.sql.ResultSet#close()}
	 *             </p>
	 */
	void close() throws SQLException;

	/**
	 * 提交事务
	 *
	 * @throws SQLException 执行异常
	 *             <p>
	 *             {@linkplain java.sql.Connection#commit()}
	 *             </p>
	 */
	void commit() throws SQLException;

	/**
	 * 事务回滚
	 *
	 * @throws SQLException 执行异常
	 *             <p>
	 *             {@linkplain java.sql.Connection#rollback()}
	 *             </p>
	 */
	void rollback() throws SQLException;

	/**
	 * 销毁对象
	 */
	void destroy();

}
